﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace Webcam.VideoSource
{
    /// <summary>
    /// A captured frame from a webcam
    /// </summary>
    public class Frame
    {
        /// <summary>
        /// The captured frame 
        /// </summary>
        public Bitmap frame = null;

        /// <summary>
        /// The time since previous frame
        /// </summary>
        public TimeSpan TimeSincePreviousFrame = TimeSpan.Zero;

        /// <summary>
        /// The FPS
        /// </summary>
        public int FPS
        {
            get { return (int)(1000 / TimeSincePreviousFrame.TotalMilliseconds); }
        }

        /// <summary>
        /// Create a frame object
        /// </summary>
        /// <param name="image">The captured image</param>
        /// <param name="timeSinceLast">The time since previous frame was captured</param>
        public Frame(Bitmap image, TimeSpan timeSinceLast)
        {
            this.frame = image;
            this.TimeSincePreviousFrame = timeSinceLast;
        }
    }
}
